package lib.weixininteract;

import lib.servlet.AuthUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * 组装入口地址
 * 进行授权页面的授权地址组装
 * @author wlw
 *
 */
@WebServlet("/wxLoginList")
public class LoginListServiet extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //回调地址（必须在公网进行访问）
        String backUrl="http://www.eyehelper.top/CallBackServlet";
        String url="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+ AuthUtil.APP_ID
                + "&redirect_uri="+URLEncoder.encode(backUrl)
                + "&response_type=code"
                + "&scope=snsapi_userinfo"
                + "&state=STATE#wechat_redirect";
        //重定向
        resp.sendRedirect(url);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        super.doPost(req, resp);
    }
}